package org.example.study.bio.cs;

import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class BIOClient {
    private static Charset charset = StandardCharsets.UTF_8;

    public static void main(String[] args) throws Exception {
        Socket s = new Socket("localhost", 8080);
        OutputStream out = s.getOutputStream();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入：");
        String msg = scanner.nextLine();
        out.write(msg.getBytes(charset)); // 阻塞式写
        scanner.close();
        s.close();
    }
}
